home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / xv_pc17.zip / HOTKEYS.INC < prev    next >
Text File  |  1994-06-24  |  2KB  |  75 lines

  1. {
  2. Accelerator keys for the XView-PC interface
  3. By Antonio Carlos Moreirao de Queiroz - acmq@coe.ufrj.br
  4. Version 1.0 - 10/04/94
  5. Version 1.1 - 24/06/94 Local variables mx and my included
  6.  
  7. This procedure implements a system of "accelerator keys" using the
  8. "interposer". The mouse will move to the center of the first object
  9. in the screen that has in its "xv_label" the letter pressed along
  10. with the "Alt" key, in upper case. The selected window becomes the
  11. active window. Buttons are pressed, textfields put in edition mode,
  12. and menus are opened.
  13. To install:
  14. Include this file, and insert after "xv_init": interposer:=HotKeys;
  15. The program must use the units Mickey and XView.
  16. }
  17.  
  18. {$I extkeys.inc}
  19.  
  20. {$F+}
  21.  
  22. PROCEDURE HotKeys;
  23. VAR
  24.   ptw,pto:Xv_opaque;
  25.   found:BOOLEAN;
  26.   pt,mx,my:INTEGER;
  27. CONST
  28.   table:ARRAY[0..35] OF INTEGER=(
  29.     kAltA,kAltB,kAltC,kAltD,KAltE,
  30.     kAltF,kAltG,kAltH,kAltI,kAltJ,
  31.     kAltK,kAltL,kAltM,kAltN,kAltO,
  32.     kAltP,kAltQ,kAltR,kAltS,kAltT,
  33.     kAltU,kAltV,kAltW,kAltX,kAltY,kAltZ,
  34.     kAlt0,kAlt1,kAlt2,kAlt3,kAlt4,
  35.     kAlt5,kAlt6,kAlt7,kAlt8,kAlt9
  36.   );
  37.  
  38. BEGIN
  39.   IF (ie_code>2000) THEN BEGIN
  40.     pt:=0; found:=FALSE;
  41.     REPEAT
  42.       IF table[pt]=ie_code THEN found:=TRUE
  43.       ELSE inc(pt)
  44.     UNTIL found or (pt>35);
  45.     IF not found THEN Exit;
  46.     IF pt>25 THEN inc(pt,Ord('0')-26) ELSE inc(pt,Ord('A'));
  47.     found:=FALSE;
  48.     ptw:=active_w;
  49.     REPEAT
  50.       pto:=ptw;
  51.       REPEAT
  52.         IF pos(Chr(pt),pto^.xv_label)<>0 THEN found:=TRUE
  53.         ELSE pto:=pto^.next
  54.       UNTIL found or (pto=nil);
  55.       IF not found THEN ptw:=ptw^.under;
  56.     UNTIL found or (ptw=active_w);
  57.     IF found THEN BEGIN
  58.       open_window(ptw);
  59.       IF pto^.o_type=frame THEN BEGIN
  60.         mx:=ptw^.x+ptw^.dx div 2;
  61.         my:=ptw^.y+mrgy div 2;
  62.       END
  63.       ELSE BEGIN
  64.         mx:=ptw^.x+mrgx+pto^.x+pto^.dx div 2;
  65.         my:=ptw^.y+mrgy+pto^.y+pto^.dy div 2;
  66.       END;
  67.       mouse_move(mx,my);
  68.       IF pto^.menu_name<>nil THEN menu_show(pto^.menu_name);
  69.       IF (pto^.o_type=button) or (pto^.o_type=textfield) THEN ie_code:=MS_LEFT;
  70.     END
  71.   END
  72. END;
  73.  
  74. {$F-}
  75.